package com.xms.web.framework.model;

/**
 * <p>
 *  前端执行结果对象
 * </p>
 *
 * @author migo
 * @since 2021-08-28
 */
public class ExecuteResult {
    public ExecuteResult()
    {
    }

    public ExecuteResult(Boolean isSuccess)
    {
        this.IsSuccess = isSuccess;
    }

    public ExecuteResult(Boolean isSuccess, Object data)
    {
        this.IsSuccess = isSuccess;
        this.Data = data;
    }

    public ExecuteResult(Boolean isSuccess, Object data, int statusCode)
    {
        this.IsSuccess = isSuccess;
        this.Data = data;
        this.StatusCode = statusCode;
    }

    public ExecuteResult(Boolean isSuccess, Object data, int statusCode, String errorMessage)
    {
        this.IsSuccess = isSuccess;
        this.Data = data;
        this.StatusCode = statusCode;
        this.ErrorMessage = errorMessage;
    }

    /// <summary>
    /// 是否成功
    /// </summary>
    public Boolean IsSuccess = true;

    /// <summary>
    /// 数据
    /// </summary>
    public Object Data = null;

    /// <summary>
    /// 错误信息
    /// </summary>
    public String ErrorMessage = null;

    /// <summary>
    /// 状态码
    /// </summary>
    public int StatusCode = 200;

    public static ExecuteResult Failure(String message)
    {
        return new ExecuteResult(false, null, 400, message);
    }

    public static ExecuteResult Failure(String message, int statusCode)
    {
        return new ExecuteResult(false, null, statusCode, message);
    }

    public static ExecuteResult Success(Object data)
    {
        return new ExecuteResult(true, data, 200);
    }

    public static ExecuteResult Success(Object data, int statusCode)
    {
        return new ExecuteResult(true, data, statusCode);
    }
}
